<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false"%>
<html>
<head>
    <title>Title</title>
    <%@ include file="static_res.jsp"%>
    <style>
        img{
            width: 90px;
            height: 90px;
        }
    </style>

    <script type="text/javascript">
        function test(){
            var form = new FormData(document.getElementById("mform"));

            $.ajax({
                url:"${pageContext.request.contextPath}/user/upload",
                type:"post",
                data:form,
                processData:false,
                contentType:false,
                dataType:"json",
                success:function(data){
                    if(data.success==false){
                        window.alert(data.error);
                    }else{
                        window.alert("成功");
                        console.log("data="+data);
                        console.log("data.data="+data.message);
                        $("#tt").attr("src",data.message);
                    }
            }});
            get();//此处为上传文件的进度条
        };
    </script>
</head>
<body>
<%@ include file="header.jsp"%>

<form id="mform"  method="post" enctype="multipart/form-data">
    <div class="file-field input-field">
        <div class="btn">
            <span>文件</span>
            <input type="file" name="file" onchange="test()">
        </div>
        <div class="file-path-wrapper">
            <input class="file-path " type="text">
        </div>
    </div>
</form>
<img id = "tt" src="" class="circle"/>
</body>
</html>
